/*    */ package com.newcrm.webapi.sub;
/*    */ 
/*    */ import com.newcrm.bean.CompanyInfo;
/*    */ import com.newcrm.bean.User;
/*    */ import com.newcrm.db.TagManager;
/*    */ import com.newcrm.exception.DBException;
/*    */ import com.newcrm.exception.NotFoundException;
/*    */ import com.newcrm.util.Util;
/*    */ import com.newcrm.webapi.AbstractAction;
/*    */ import com.newcrm.webapi.AbstractHttpServlet;
/*    */ import java.io.IOException;
/*    */ import java.io.PrintWriter;
/*    */ import javax.servlet.ServletException;
/*    */ import javax.servlet.http.HttpServletRequest;
/*    */ import javax.servlet.http.HttpServletResponse;
/*    */ import net.sf.json.JSONObject;
/*    */ import org.apache.log4j.Logger;
/*    */ 
/*    */ public class UpdateTag extends AbstractAction
/*    */ {
/* 25 */   private static Logger logger = Logger.getLogger(UpdateTag.class.getName());
/*    */ 
/* 27 */   private int id = 0;
/*    */ 
/*    */   public UpdateTag(AbstractHttpServlet servlet) {
/* 30 */     super(servlet);
/*    */   }
/*    */ 
/*    */   public UpdateTag(AbstractHttpServlet servlet, String id) {
/* 34 */     super(servlet);
/* 35 */     this.id = Util.str2Int(id);
/*    */   }
/*    */ 
/*    */   public void parse(HttpServletRequest request, HttpServletResponse response)
/*    */     throws IOException, ServletException, NotFoundException
/*    */   {
/* 42 */     String tagName = Util.getURLParameter(request.getParameter("tagName"));
/*    */ 
/* 44 */     User loginUser = super.getLoginUser(request);
/* 45 */     TagManager manager = new TagManager();
/* 46 */     int result = manager.update(this.id, tagName, loginUser.companyId);
/* 47 */     JSONObject jsonObject = new JSONObject();
/* 48 */     if (result <= 0) {
/* 49 */       jsonObject.put("error", "1");
/*    */     } else {
/* 51 */       jsonObject.put("error", "0");
/*    */ 
/* 53 */       CompanyInfo company = super.getCompany(loginUser.companyId);
/*    */       try {
/* 55 */         company.tags = manager.list(loginUser.companyId);
/*    */       } catch (DBException e) {
/* 57 */         logger.warn("update group failed", e);
/*    */       }
/*    */     }
/* 60 */     response.setContentType("text/html;charset=utf-8");
/* 61 */     PrintWriter out = response.getWriter();
/* 62 */     out.println(jsonObject);
/* 63 */     out.flush();
/* 64 */     out.close();
/*    */   }
/*    */ }

/* Location:           C:\E\referenceProject\CRM参考\qikebao\WEB-INF\lib\qikebao.jar
 * Qualified Name:     com.newcrm.webapi.sub.UpdateTag
 * JD-Core Version:    0.6.1
 */